package com.jt.tenant.db;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.zcx.helper.db.SQLiteTable;
import com.zcx.helper.db.note.SQLiteTableInfo;

import java.util.ArrayList;
import java.util.List;

@SQLiteTableInfo(name = "province", structure = { "abbr", "province", "xuhao", "admin_code" })
public class JTProvince extends SQLiteTable{

	public List<Province> queryAll(){

		List<Province> list = new ArrayList<>();

		SQLiteDatabase sqLiteDatabase = dataBase.getReadableDatabase();

		Cursor cursor = sqLiteDatabase.query("province", null, null, null, null, null, null);

		if (cursor.moveToFirst()) {

			do{

				Province province = new Province();

				province.abbr = cursor.getString(cursor.getColumnIndex("abbr"));

				province.province = cursor.getString(cursor.getColumnIndex("province"));

				province.xuhao = cursor.getString(cursor.getColumnIndex("xuhao"));

				province.admin_code = cursor.getString(cursor.getColumnIndex("admin_code"));

				list.add(province);

			}while (cursor.moveToNext());

		}

		return list;

	}

	public static class Province{

		public String abbr, province, xuhao, admin_code;

	}

}
